package com.binarysoft.service.type;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.binarysoft.service.type.Types;

public class TypesSqlProvider {

    public String insertSelective(Types record) {
        BEGIN();
        INSERT_INTO("TYPES");
        
        if (record.getTypeId() != null) {
            VALUES("TYPE_ID", "#{typeId,jdbcType=VARCHAR}");
        }
        
        if (record.getTypeName() != null) {
            VALUES("TYPE_NAME", "#{typeName,jdbcType=VARCHAR}");
        }
        
        if (record.getTypeDesc() != null) {
            VALUES("TYPE_DESC", "#{typeDesc,jdbcType=VARCHAR}");
        }
        
        if (record.getParentId() != null) {
            VALUES("PARENT_ID", "#{parentId,jdbcType=VARCHAR}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(Types record) {
        BEGIN();
        UPDATE("TYPES");
        
        if (record.getTypeName() != null) {
            SET("TYPE_NAME = #{typeName,jdbcType=VARCHAR}");
        }
        
        if (record.getTypeDesc() != null) {
            SET("TYPE_DESC = #{typeDesc,jdbcType=VARCHAR}");
        }
        
        if (record.getParentId() != null) {
            SET("PARENT_ID = #{parentId,jdbcType=VARCHAR}");
        }
        
        WHERE("TYPE_ID = #{typeId,jdbcType=VARCHAR}");
        
        return SQL();
    }
}